<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/includes.jsp" %>
<html>
 <head>
    <title>采购(原材料/成品)退货管理</title>
    <!-- import css and js -->
	<%@ include file="/common/meta.jsp" %>
	<script src="${ctx}/js/ligerUI/js/plugins/ligerLayout.js" type="text/javascript"></script>
	<script src="${ctx}/js/jsp/comm.js" type="text/javascript"></script>
	<script type="text/javascript">
		var basic_Url="${ctx}/logic/purchasereturn";
		var basic_WUrl="logic/purchasereturn";
		var basic_Title="采购退货";
		var show_Width=880;
		var show_Hight=500;
		function createSearch(){
			init(2,8,'100,100,100,100,100,100,100,100','10%');
			//第一行的数据
			addCommon(0,0,"lable","采购订单单号：");
			addCommon(0,1,"txtlike","zd001PcsCode");
			addCommon(0,2,"lable","采购入库单号：");
			addCommon(0,3,"txtlike","zd002PcsmCode");
			addCommon(0,4,"lable","退货单号：");
			addCommon(0,5,"txtlike","zd003Code");
			addCommon(1,0,"lable","仓库");
			addCommon(1,1,"selectEnum","zd007WhName","<option></option><c:forEach var="s" items="${wh}"><option value='${s.zd003Name}'>${s.zd003Name}</option></c:forEach>");
			addCommon(1,2,"lable","单据状态：");
			addCommon(1,3,"selectEnum","zd006Status","<option></option><option value='PCSR_SAVE'>草稿</option><option value='PCSR_BACK'>驳回</option>"+
					"<option value='PCSR_SUBMIT'>待二级审批</option><option value='PCSR_AUDIT'>待三级审批</option><option value='PCSR_APPROVE'>审核完成</option>");
		}
		
		function searchAP(){
			multipleSearch("#table1",true,"",basic_Url+"/list.do");
		}
		document.onkeydown=keyListener;   
		function keyListener(e){   
		    e = e ? e : event;  
		    if(e.keyCode == 13){   
		    	searchAP();
		    }   
		}  
		function checkdel(){
			var manager = $("#table1").ligerGetGridManager(); 
			var rows = manager.getSelectedRows();
			var bol = false;
			if (rows==null){
				$.dialog.alert('请选择需要操作删除的行！');
				return;
			}else{
				for(var i=0;i<rows.length;i++){
				 	if (rows[i].bizCreatorName !='${user.name}'){
				 		bol = true;
					}
				}
				if(bol){
					$.dialog.alert('只能对本人建的单据进行删除操作!');
					return;
				}else{
					bol = false;
					for(var i=0;i<rows.length;i++){
					 	if (rows[i].zd006Status == 'PCSR_SAVE' || rows[i].zd006Status =='PCSW_BACK'){
					 		bol = true;
						}
					}
					if(bol){
						del();
						bol = false;
					}else{
						$.dialog.alert('草稿或驳回状态的单据才能进行删除!');
						return;
					}
				}
			}
			
		}
		$(function(){
			var grid = $("#table1").ligerGrid({
		        columns: [{ display: 'id', name: 'id', hide : true },
		                  { display: '退货单号', name: 'zd003Code', width: 190 },
		                  { display: '采购编号', name: 'zd001PcsCode', width: 190 },
		                  { display: '采购入库单号', name: 'zd002PcsmCode', width: 190 },
		                  { display: '仓库名称', name: 'zd007WhName', width: 110},
		                  { display: '单据状态', name: 'zd006Status', width: 110,
		                	  render: function (item){
		                		  var billStatus=item.zd006Status;
		                		  if(billStatus=="PCSR_SAVE"){
		                			  return "草稿";
		                		  }if(billStatus=="PCSR_SUBMIT"){
		                			  return "待二级审批";
		                		  }
		                		  if(billStatus=="PCSR_AUDIT"){
		                			  return "待三级审批";
		                		  } 
		                		  if(billStatus=="PCSR_APPROVE"){
		                			  return "审核完成";
		                		  }
		                		  if(billStatus=='PCSR_BACK'){
		                			  return "驳回";
		                		  }
		                  }},
		                  { display: '退款状态', name: 'zd006Status', width: 110,
		                	  render: function (item){
		                		  var billStatus=item.zd006PayStatus;
		                		  if(billStatus=="RENO"){
		                			  return "未退款";
		                		  }if(billStatus=="SECT"){
		                			  return "部分退款";
		                		  }
		                		  if(billStatus=="COMP"){
		                			  return "完全退款";
		                		  } 
		                  }},
		                  { display: '创建人', name: 'bizCreatorName', width: 150},	  
		                  { display: '退货日期', name: 'bizCreatorDate', width: 120,
		                	  render: function (item){
		                		  var cdate=new Date(item.bizCreatorDate);
		                		  return formatDate(cdate,"yyyy-MM-dd");
		                  }},
		                  { display: '备注', name: 'zd013Remark', width: 120 }
		                      ],  usePager: true,pageSize:15,pageSizeOptions :[15,30,45,60],enabledSort:false,
		                      url : basic_Url+"/list.do",
		                      width: "100%", height:"98%", checkbox: true,rownumbers:true,      
		                      onDblClickRow : function (data, rowindex, rowobj){
		                    	  edit(data);
		                      }
		                  });
			$("#pageloading").hide();
		});
	</script>
	
  </head>
 <body style="padding:10px" onLoad="createSearch()">  
       <div id="layout1">
          <div class="panelBar">
	            <ul class="toolBar">
		           <li><a class="add" onclick="add()"><span>新增</span></a></li>
				 <li><a class="delete" onclick="checkdel()"><span>删除</span></a></li>
               </ul>
          </div>
          <div id="pageHeader" class="pageHeader">
               <div class="searchBar" id="multipleSearchDialog">
	                <table class="table" width="100%" id="searchHeader" >  
                        <tbody id="newbody">
                        </tbody>
 	                </table>
                    <div class="subBar">
			             <ul>
				             <li><div class="buttonActive"><div class="buttonContent"><button type="submit" id="btnSearch" onclick="searchAP()">查询</button></div></div></li>
				             <li><a class="button" onclick="clearSearch()"><span>重置</span></a></li>
			             </ul>
	                </div>
               </div>
          </div>
      </div>
      <div position="center" id="table1">
      </div>
      <div class="clear"></div>
    </body>
</html>